package com.lmf.eduservice.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lmf.eduservice.entity.EduCourse;
import com.lmf.eduservice.entity.frontVo.CourseFrontVo;
import com.lmf.eduservice.service.EduChapterService;
import com.lmf.eduservice.service.EduCourseService;
import com.lmf.resultCode.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(description = "前台课程控制器")
@CrossOrigin
@RestController
@RequestMapping("/eduservice/courseFront")
public class CourseFrontController {

    @Autowired
    private EduCourseService eduCourseService;
    @Autowired
    private EduChapterService eduChapterService;

    @ApiOperation("按条件分页查询课程")
    @PostMapping("/getCourseFrontList/{pages}/{limit}")
    public R getCourseFrontList(@PathVariable Long pages, @PathVariable Long limit,
                                @RequestBody(required = false) CourseFrontVo courseFrontVo){
        Page<EduCourse> page = new Page<>(pages,limit);

        Map<String,Object> map = eduCourseService.getCourseFrontInfo(page,courseFrontVo);

        return R.ok().data("map",map);
    }
}
